﻿namespace EHR18
{
    public interface IMaster
    {
        /// <summary>
        /// 读取多个状态位
        /// </summary>
        /// <param name="slave">从机地址</param>
        /// <param name="startAddress">起始地址</param>
        /// <param name="nCoils">读取位数</param>
        /// <returns></returns>
        bool[] ReadCoils(byte slave, ushort startAddress, ushort nCoils);
        /// <summary>
        /// 写入多个状态位
        /// </summary>
        /// <param name="slave">从机地址</param>
        /// <param name="startAddress">起始地址</param>
        /// <param name="data">写入位数组</param>
        ushort[] ReadHoldingRegisters(byte slave, ushort startAddress, ushort nRegister);
        /// <summary>
        /// 读取寄存器的值
        /// </summary>
        /// <param name="slave">从机地址</param>
        /// <param name="startAddress">起始地址</param>
        /// <param name="nRegister">数量</param>
        /// <returns>寄存器返回值</returns>
        void WriteCoils(byte slave, ushort startAddress, bool[] data);
        /// <summary>
        /// 写入多个寄存器
        /// </summary>
        /// <param name="slave">从机地址</param>
        /// <param name="startAddress">起始地址</param>
        /// <param name="data">需要写入的数据</param>
        void WriteHoldingRegisters(byte slave, ushort startAddress, ushort[] data);
    }
}